// 默认模块的导出
/**
 * @method isType 方法名称,判断数据类型
 * @param {*} value 需要判断的数据
 * @param {String} typeName 要判断的数据类型,不传则返回数据类型,传则返回true|false
 * typeName 可选值: |'Number',|'string',|'boolean',|'undefined',|'null',|'array',|'object',|'date',|'regExp',|'function',|'symbol',
 */
const TYPE_LSIT = [
    'Number',
    'string',
    'boolean',
    'undefined',
    'null',
    'array',
    'object',
    'date',
    'regExp',
    'function',
    'symbol',] as const;
type typeNameRules = typeof TYPE_LSIT[number];
export const isType = (value: any, typeName?: typeNameRules): string | boolean => {
    const type = Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
    if (typeName && !TYPE_LSIT.includes(typeName as typeNameRules)) {
        throw new TypeError(
            `type:${type} 不存在,请传入指定的类型:${TYPE_LSIT.join(",")}`
        );
    }
    if (typeName) {
        return type === typeName;
    } else {
        return type;
    }
}